#########################################################
#	Build Realtek OMCI modules		#
#########################################################
RTKDRV_RELEASE_VERSION			= \"A.2.5\"
include $(APOLLODIR)/Compiler_Flag
ifeq ($(shell [ $(CONFIG_COMMON_RT_API) = y ] || [ $(CONFIG_LUNA_G3_SERIES) = y ] && echo true),true)
all:
	@echo "done"

install:
	@echo "done"

clean:
	@echo "done"
else
MODULE_NAME=pf_rtk
PWD=$(shell pwd)
SDKDIR=$(APOLLODIR)/sdk
SDK_INCLUDE   = $(SDKDIR)/include
SYS_INCLUDE   = $(SDKDIR)/system/include
DRV_INCLUDE   = $(SDKDIR)/system/linux
OMCIDIR=$(OMCIROOT_DIR)
OMCISRCDIR=$(OMCIDIR)/OMCI/src
OMCIDRVDIR=$(OMCIDIR)/DRV
OMCI_API_INCLUDE = $(OMCIDIR)/API
MODULEDIR=$(SDKDIR)/src/module
ROOT_INCLUDE = $(ROOTDIR)/include

KBUILD_EXTRA_SYMBOLS += $(OMCIDRVDIR)/Module.symvers

EXTRA_CFLAGS += -Wall -Werror -Wframe-larger-than=2048 -Wno-unused-function
EXTRA_CFLAGS += -I$(SDK_INCLUDE) \
		-I$(DRV_INCLUDE) \
		-I$(SYS_INCLUDE) \
		-I$(MODULEDIR) \
		-I$(OMCIDIR) \
		-I$(OMCISRCDIR) \
		-I$(OMCIDRVDIR) \
		-I$(OMCI_API_INCLUDE) \
		-I$(NETDIR) \
		-I$(ROOT_INCLUDE) \
		-DCONFIG_SDK_KERNEL_LINUX

ifdef RTKDRV_RELEASE_VERSION
EXTRA_CFLAGS += -DCONFIG_DRV_RELEASE_VERSION="$(RTKDRV_RELEASE_VERSION)"
endif
EXTRA_CFLAGS += $(PON_CFLAGS)

obj-m := $(MODULE_NAME).o

$(MODULE_NAME)-objs:= omci_pf_rtl9607.o

all:
	@echo "   BUILD module $(MODULE_NAME)"
	$(MAKE) -C $(KERNEL_DIR) M=$(PWD) ARCH=rlx CROSS_COMPILE=$(CROSS_COMPILE) || exit 1

install:
	@if [ ! -d $(ROMFSDIR)/lib/modules ]; \
        then \
                mkdir $(ROMFSDIR)/lib/modules ; \
        fi
	cp -af $(MODULE_NAME).ko $(ROMFSDIR)/lib/modules/

clean:
	rm -rf *.o *~ core .depend .*.cmd *.mod.c .tmp_versions *.symvers *.ko modules.order
endif
